
const arr = [22, "hello", "123", "!", 99, 1]
// const arr = [22, 23, 5, 99, 1]
console.log(arr.reduce((prev, curr) => {
  return prev + curr.toString().repeat(2)
}))
/*
console.log(arr.reduce((prev, current, index) => {
  // console.log(index)
  // console.log(current)
  console.log(prev)
  return prev + current
}))*/

// forEach 无返回值
// map 返回一个新数组
// find 返回搜索到的item
// findIndex 返回搜索到的item的index
// filter 返回一个按条件过滤后的数组
// every 返回布尔值，每一个都得符合条件
// some 返回布尔值，部分符合条件
// reduce 返回累加值

// console.log(arr.some((item) => typeof item === "number"))
// console.log(arr.every((item) => typeof item === "number"))

// console.log(arr.filter((item) => typeof item === "number"))
// console.log(arr.filter((item) => typeof item !== "number"))


/*
console.log(arr.forEach((item) => {
  // console.log(item)
  return 123
}))

console.log(arr.map((item) => {
  // console.log(item)
  if (typeof item === "number") {
    return item * 2
  }
  return item.repeat(2)
}))
*/


// console.log(arr.includes(1))
// console.log(arr.includes("1"))
// const res = arr.find((item, index) => {
/*
const res = arr.findIndex((item, index) => {
  // console.log(item, index)
  // return index === 3
  // return typeof item === "string"
  return item === +"1"
})
console.log(res)*/


